#include "VulkanApplication.h"
#include <vector>
#include <iostream>

void mouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
{
    printf("MOUSEBUTTON: %d, %d\n", button, action);
}

void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    printf("KEY: %d, %d\n", key, action);
    if (key == GLFW_KEY_ESCAPE) glfwSetWindowShouldClose(window, 1);
}

void resizeCallback(GLFWwindow* window, int width, int height)
{
    printf("Resized: %d x %d\n", width, height);
}

int main(int argc, char** argv)
{
    VulkanApplication app("c03_surface");
    if (!app.initialized())
    {
        printf("Failed to initialize VulkanApplication.\n");
        return 1;
    }

    glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
    GLFWwindow* window = glfwCreateWindow(1024, 768, "c03_surface", nullptr, nullptr);
    if (!window)
    {
        printf("Failed to create GLFW window.\n");
        return 1;
    }

    VkSurfaceKHR surface;
    VkResult result = glfwCreateWindowSurface(app.getInstance(), window, nullptr, &surface);
    if (result != VK_SUCCESS)
    {
        printf("Failed to create window surface.\n");
        return 1;
    }

    // TODO
    glfwSetMouseButtonCallback(window, mouseButtonCallback);
    glfwSetKeyCallback(window, keyCallback);
    glfwSetWindowSizeCallback(window, resizeCallback);
    while (!glfwWindowShouldClose(window))
    {
        glfwPollEvents();
    }

    vkDestroySurfaceKHR(app.getInstance(), surface, nullptr);
    glfwDestroyWindow(window);
    return 0;
}